package fhedu;

import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;

public class ThongBao extends GameCanvas {
    int focus=0,focus1=9;
    int i,j,k,i1;
    int y;
    int x;
    Graphics g = getGraphics();
    CellList manglist[]=new CellList[20];
    Graphics glist= getGraphics();
    ThongBao() throws IOException{
        super(false);
        Giaodienthongbao();
    } 
 
     
    void Giaodienthongbao() throws IOException{
        
        try{
            Image thongbaoimg= Image.createImage("Image/logothongbao.png");
            g.drawImage(thongbaoimg, 40, 2, Graphics.TOP|Graphics.LEFT);
        } catch(Exception e){};      
        g.setFont(MyFont.fontnhodam);
        g.setColor(255,0,0);
        String ten = "Nguyễn Hoàng Anh" ;
        g.drawString("Người nhận: " +ten, 20, 65, Graphics.TOP|Graphics.LEFT);
        g.setFont(MyFont.fontnhodam);
        x=10;y=85;
        manglist[0]=new CellList();
        manglist[0].CellList(glist,10,85);
        //y=105;
        manglist[1]=new CellList();
        manglist[1].CellList(glist,10,105);
        //y=125;
        manglist[2]=new CellList();
        manglist[2].CellList(glist,10,125);
        //y=145;
        manglist[3]=new CellList();
        manglist[3].CellList(glist,10,145);
        //y=165;
        manglist[4]=new CellList();
        manglist[4].CellList(glist,10,165);
        //y=185;
        manglist[5]=new CellList();
        manglist[5].CellList(glist,10,185);
        //y=205;
        manglist[6]=new CellList();
        manglist[6].CellList(glist,10,205);
        //y=225;
        manglist[7]=new CellList();
        manglist[7].CellList(glist,10,225);
        //y=245;
        manglist[8]=new CellList();
        manglist[8].CellList(glist,10,245);
        g.drawString("Thời gian", 12, 87, Graphics.TOP|Graphics.LEFT);
        g.drawString("Tiêu đề",125,87,Graphics.TOP|Graphics.LEFT);
        g.drawLine(70, 85, 70, 265);
        manglist[focus].FoCus(glist);
        flushGraphics();
        manglist[9]=new CellList();
        manglist[9].CellPage(glist, 85, 280);                       
        manglist[10]=new CellList();
        manglist[10].CellPage(glist, 100, 280);
        manglist[11]=new CellList();
        manglist[11].CellPage(glist, 115, 280);
        manglist[12]=new CellList();
        manglist[12].CellPage(glist, 130, 280);
        manglist[13]=new CellList();
        manglist[13].CellPage(glist, 145, 280);
        
        manglist[focus1].FocusPage(glist);
        g.setFont(MyFont.fontnhodam);
        g.drawString("Trang: ", 45, 280, Graphics.TOP|Graphics.LEFT);
        g.drawString("1",90,280,Graphics.TOP|Graphics.LEFT);
        g.drawString("2",105,280,Graphics.TOP|Graphics.LEFT);
        g.drawString("3",120,280,Graphics.TOP|Graphics.LEFT);
        g.drawString("4",135,280,  Graphics.TOP|Graphics.LEFT);
        g.drawString("5",150,280,  Graphics.TOP|Graphics.LEFT);
        flushGraphics();
    }
    void refresh(Graphics g) throws IOException
    {
        Giaodienthongbao();       
        flushGraphics();
    }
    public void keyPressed(int k)
    {
        switch(getGameAction(k))
        {
            case UP:
                if(focus>0)
                {
                 
                manglist[focus].UnFocus(glist);
                manglist[focus-1].FoCus(glist);
                focus-=1;    
                flushGraphics();
                }
                break;
            case DOWN:
                if(focus<8)
                {
                manglist[focus].UnFocus(glist);
                manglist[focus+1].FoCus(glist);
                focus+=1;    
                flushGraphics();
                }
                break;
            case LEFT:
                if(focus1>9)
                {
                    manglist[focus1].UnFocusPage(glist);
                    manglist[focus1-1].FocusPage(glist);
                    focus1-=1;
                    flushGraphics();
                }                              
                break;
            case RIGHT:
                if(focus1<13)
                {
                    manglist[focus1].UnFocusPage(glist);
                    manglist[focus1+1].FocusPage(glist);
                    focus1+=1;
                    flushGraphics();
                }
               break;
            case FIRE:
                if((0<focus)&&(focus<9))
                {
                    manglist=null;
                    glist=null;
                    FHEDU.display.setCurrent(new ThongBaoChiTiet());
                }
               break;
        }
    }   
   }
  

    
   
